package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.BillDishDao;
import com.chhlz.module.base.model.BillDish;
import com.chhlz.module.service.BillDishService;

@Service
public class BillDishServiceImpl implements BillDishService{
	@Autowired
	BillDishDao billDishDao;

	@Override
	public int getTotal() {
		return this.billDishDao.countAll();
	}

	@Override
	public boolean isExist(int billId, int dishId) {
		boolean flag = false;
		String hql = "select * from BillDish bd where bd.billId=" + billId + " and bd.dishId=" + dishId;
		if(this.billDishDao.find(hql).size()>0)
			flag = true;
		return flag;
	}

	@Override
	public int save(BillDish t) {
		return this.billDishDao.save(t);
	}

	@Override
	public void update(BillDish t) {
		this.billDishDao.update(t);
	}

	@Override
	public void delete(int id) {
		BillDish bd = this.billDishDao.get(id);
		this.billDishDao.delete(bd);
	}

	@Override
	public List<BillDish> findAll(int page, int rows, String sort, String order) {
		return this.billDishDao.findAll(page, rows, sort, order);
	}

}
